package com.dzqc.fly.controller.mobile;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dzqc.fly.common.Kv;
import com.dzqc.fly.common.Result;
import com.dzqc.fly.db.form.SecretaryForm;
import com.dzqc.fly.db.form.SecretaryQueryForm;
import com.dzqc.fly.db.pojo.SecretaryStudentsPojo;
import com.dzqc.fly.db.pojo.StudentsLeavePojo;
import com.dzqc.fly.db.vo.SecretaryStudentDetailVo;
import com.dzqc.fly.db.vo.SecretaryStudentsTimeVo;
import com.dzqc.fly.db.vo.SecretarySumVo;
import com.dzqc.fly.service.SecretaryQueryService;
import com.dzqc.fly.service.SecretaryStudentsService;
import com.dzqc.fly.service.SecretarySumService;
import com.dzqc.fly.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.HashMap;


/**
 * @author Administrator
 */
@RestController
@RequestMapping("/secretary/query")
@Tag(name = "SecretarySumController", description = "手机端用户Web接口")
@Slf4j
@EnableAutoConfiguration
public class SecretaryQueryController {

    @Autowired
    private UserService userService;
    @Autowired
    private SecretaryQueryService secretaryQueryService;

    //@GetMapping("/searchStatusList")
    @RequestMapping(value="/searchStatusList" ,method = RequestMethod.GET)
    @Operation(summary = "书记辖内班级学生列表")
    @SaCheckLogin
    public Result searchStudentList(@Valid SecretaryQueryForm secretaryQueryForm){
        //secretaryQueryForm.setStatusStr(secretaryQueryForm.statusToString());
        HashMap userinfoMap =userService.searchUserInfo(StpUtil.getLoginIdAsInt());
        HashMap param= (HashMap) Kv.toKv(secretaryQueryForm);
        param.put("sno",userinfoMap.get("sno"));
        Page<StudentsLeavePojo> result=secretaryQueryService.searchStatusList(param);
        return Result.commonOk(result);
    }

}
